#include "KingPig.h"
#include "Animation.h"

KingPig::KingPig(void)
: TexturedEntity()
{
    m_position = Vector3();
    m_pixelsSize = Dimension();
}

KingPig::KingPig(boost::shared_ptr<Scene> scene, const Vector3& position, const Dimension& size)
: TexturedEntity(scene, "data/textures/ingamebirds1.tga")
{
    m_position = position;
    m_pixelsSize = size;
}

KingPig::~KingPig(void)
{
}

bool KingPig::onInitialize()
{
    // Specific initialization
    setPositionInTexture(Vector3(42.0f, 816.0f, 0.0f));
    setSizeInTexture(Dimension(124.0f, 148.0f));

    // Create and attach an animation
    Animation* animation = new Animation(this);
    animation->setLoop(true);
    
    // First animation frame
    AnimationFrame frame1(Vector3(42.0f, 816.0f, 0.0f), Dimension(124.0f, 148.0f), 4.0f);
    animation->addFrame(frame1);

    // Second animation frame
    AnimationFrame frame2(Vector3(42.0f, 351.0f, 0.0f), Dimension(124.0f, 148.0f), 0.15f);
    animation->addFrame(frame2);

    // Third animation frame
    AnimationFrame frame3(Vector3(42.0f, 816.0f, 0.0f), Dimension(124.0f, 148.0f), 0.35f);
    animation->addFrame(frame3);

    // Fourth animation frame
    AnimationFrame frame4(Vector3(42.0f, 351.0f, 0.0f), Dimension(124.0f, 148.0f), 0.15f);
    animation->addFrame(frame4);

    attachAnimation(animation);

    // Common initialization from base class
    return commonInit();
}

void KingPig::onPrepare(float dT)
{
    // Common process from base class
    commonPrepare(dT);
}

void KingPig::onDestroy(void)
{
}
